package A;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

public class Test_07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请选择：");
        System.out.println("1、发牌\n2、结束发牌");
        Random rd = new Random();
        List<Integer> list = new ArrayList<>();
        int sum = 0;
        while (true) {
            int number = sc.nextInt();
            switch (number) {
                case 1:
                    list.add(rd.nextInt(13) + 1);
                    sum += list.get(list.size() - 1);
                    if (sum <= 21) {
                        System.out.print("现在你的牌有：");
                        for (Integer integer : list) {
                            System.out.print(integer + " ");
                        }
                        System.out.println();
                        System.out.println("累加点数为：" + sum);
                        break;
                    } else {
                        System.out.println("累加点数为："+sum+" ,大于21结束游戏");
                        return;
                    }
                case 2:
                    System.out.print("现在你的牌有：");
                    for (Integer integer : list) {
                        System.out.print(integer + " ");
                    }
                    System.out.println();
                    System.out.println("累加点数为：" + sum);
                    return;
            }
        }
    }
}
